import Vue from 'vue'
import App from './App.vue'
import router from './router'
import axios from "axios"
import './plugins/element.js'
import "./assets/css/global.css"
import "./assets/fonts/iconfont.css"
import TreeTable from 'vue-table-with-tree-grid'
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
import NProgress from "nprogress"
import "nprogress/nprogress.css"
Vue.use(VueQuillEditor)
Vue.component("tree-table", TreeTable)
Vue.config.productionTip = false
axios.defaults.baseURL = "http://127.0.0.1:8888/api/private/v1/"
axios.interceptors.request.use(config => {
  config.headers.Authorization = sessionStorage.getItem("token")
  NProgress.start()
  return config;
})
axios.interceptors.response.use(response => {
  NProgress.done();
  return response.data;
})
Vue.filter("dateFormat", (originVal) => {
  let date = new Date(originVal)
  let y = date.getFullYear()
  let m = (date.getMonth() + 1).toString().padStart(2, "0")
  let d = (date.getDay()).toString().padStart(2, "0")
  let hh = (date.getHours()).toString().padStart(2, "0")
  let mm = (date.getMinutes()).toString().padStart(2, "0")
  let ss = (date.getSeconds()).toString().padStart(2, "0")
  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})
Vue.prototype.$http = axios;
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
